//public.js ???? JavaScript ??
//????????????????????????????????????????????????
//
//han_feng 2003.8

//????????
var	_INCLUDE_PUBLIC_JS = "YES";

///////////////////// ???????? ////////////////////////////////////

var CONTEXT_ROOT="/";					//????????
var COOKIES_JS_PATH = "js/cookies.js";		//cookies ??????????????
var THEME_JS_PATH = "theme/theme.js";		//??????????????????
var VALIDATE_JS_PATH = "js/validate.js";	//??????????????????
var BUTTON_JS_PATH = "js/button.js";		//??????????????????
var TABPANE_JS_PATH = "js/tabpane.js";		//??????????????????

var FLOW_DATA_MAXSIZE = 60;					//??????????????????????

///////////////////// ???????????? ///////////////////////////////
function includeJSFile( filePath ) {
	document.write( "<SCRIPT LANGUAGE=\"JavaScript\" src=\""
						+ CONTEXT_ROOT + filePath +"\"></SCRIPT>" );
}

function includeCSSFile( filePath ) {
	document.write( "<LINK href=\""
						+ CONTEXT_ROOT
						+ filePath + "\" rel=\"stylesheet\" type=\"text/css\">" );
}

includeJSFile( COOKIES_JS_PATH );
includeJSFile( THEME_JS_PATH );
includeJSFile( TABPANE_JS_PATH );

///////////////////// ???????? //////////////////
//???????????? trim ?????????? String ??????????????????????????????
String.prototype.trim = function()
{
    // ??????????????????????????????????????
    return this.replace(/(^\s*)|(\s*$)/g, "");
}

function maxLength(field, maxlimit) {
	var len=field.value.length;
	var num=0;
	var p=0;
	for(i=0;i<len;i++){
		var tmp=field.value.charCodeAt(i);
		if(tmp<=255) num++;
		else num=num+2;

		if (num > maxlimit){
			//window.event.returnValue=false;
			//alert("["+i+"]["+num+"]"+tmp);
			if(tmp==10)
				field.value = field.value.substring(0,i-1);
			else if(tmp==13)
				field.value = field.value.substring(0,i);
			else field.value = field.value.substring(0, p+1);

			return false;
		}else
			p=i;
	}
	return true;
}

function popModalDialog(sURL,dataObj,dialogStyle){

	if(dataObj==null){
		dataObj=new Object();
	}
	dataObj.isLogin=true;

	var openerURL = "frame/dialog.jsp?URL=";
	var result=window.showModalDialog(CONTEXT_ROOT + openerURL + sURL ,dataObj,dialogStyle);

	if(!dataObj.isLogin)top.location=dataObj.url;
	return result;
}

///////////////////// ???????? ////////////////////
//????????????????
function toTaskList(){
	location = CONTEXT_ROOT + "task/taskList.do";
}

//????????????

function displayHTML(oBody){
	showModalDialog( CONTEXT_ROOT + "frame/testDialog.htm", oBody,
		"status:no;resizable:yes;dialogHeight:600px;dialogWidth:800px;");
}
//////////////////// ?????????? ///////////////////
//??????????????
function selectDepartment(){
	var deptData=new Object();
	if(popModalDialog( CONTEXT_ROOT + "system/common/selectDepartment.do?actionType=popWin",
				 deptData,
			 	'status:no;dialogWidth:800px;dialogHeight:600px'))
		return deptData;
	else
		return null;
}
function selectSubDepartment(headCode){
	var deptData=new Object();
	if(popModalDialog( CONTEXT_ROOT + "system/common/selectDepartment.do?actionType=popWin&isHead="+headCode,
				 deptData,
			 	'status:no;dialogWidth:800px;dialogHeight:600px'))
		return deptData;
	else
		return null;
}
//
function selectDepartmentTreeAll(){
	var deptData=new Object();
	if(popModalDialog( CONTEXT_ROOT + "system/common/selectDptTree.do?actionType=popWin&operAtt=selectAll",
				 deptData,
			 	'status:no;dialogWidth:800px;dialogHeight:600px'))
		return deptData;
	else
		return null;
}

function selectDepartmentTree(){
	var deptData=new Object();
	if(popModalDialog( CONTEXT_ROOT + "system/common/selectDptTree.do?actionType=popWin",
				 deptData,
			 	'status:no;dialogWidth:800px;dialogHeight:600px'))
		return deptData;
	else
		return null;
}

function selectMutiDepartmentTreeAll(deptCodes,deptNames){
	var deptData=new Object();
	if(popModalDialog( CONTEXT_ROOT + "system/common/selectDptTree.do?actionType=Muti&operAtt=selectAll&deptCodes="+deptCodes+"&deptNames="+deptNames,
				 deptData,
			 	'status:no;dialogWidth:800px;dialogHeight:600px'))
		return deptData;
	else
		return null;
}

function selectMutiDepartmentTree(deptCodes,deptNames){
	var deptData=new Object();
	if(popModalDialog( CONTEXT_ROOT + "system/common/selectDptTree.do?actionType=Muti&deptCodes="+deptCodes+"&deptNames="+deptNames,
				 deptData,
			 	'status:no;dialogWidth:800px;dialogHeight:600px'))
		return deptData;
	else
		return null;
}
//????????????????
function selectOperator(){
	var operatorData=new Object();
	if(popModalDialog( CONTEXT_ROOT + "system/common/selectOperator.do?actionType=popWin",
				 operatorData,
			 	'status:no;dialogWidth:800px;dialogHeight:600px'))
		return operatorData;
	else
		return null;
}

function selectMultiOperator(operatorIDs,operatorNames){
	var operatorData=new Object();
	if(popModalDialog( CONTEXT_ROOT + "system/common/selectOperator.do?actionType=popWin&operAtt=selectMulti&operatorIDs="+operatorIDs+"&operatorNames="+operatorNames,
				 operatorData,
			 	'status:no;dialogWidth:800px;dialogHeight:600px'))
		return operatorData;
	else
		return null;
}
//
function selectTask(){
	var taskData=new Object();
	if(popModalDialog( CONTEXT_ROOT + "system/common/selectTask.do?actionType=popWin",
				 taskData,
			 	'status:no;dialogWidth:800px;dialogHeight:600px'))
		return taskData;
	else
		return null;
}
//
function selectSwimelane(){
	var swimlaneData=new Object();
	if(popModalDialog( CONTEXT_ROOT + "system/common/selectSwimlane.do?actionType=popWin",
				 swimlaneData,
			 	'status:no;dialognWidth:800px;dialogHeight:600px'))
		return swimlaneData;
	else
		return null;
}

//??????????????????
function selectIndustryType(){
	var industryTypeData=new Object();
	if(popModalDialog( CONTEXT_ROOT + "system/common/selectIndustryType.do",
				 industryTypeData,
			 	'status:no;dialogWidth:800px;dialogHeight:600px'))
		return industryTypeData;
	else
		return null;
}


//??????????????????????
function selectBusinessOfMI(){
	var businessOfMIData=new Object();
	if(popModalDialog( CONTEXT_ROOT + "system/common/selectBusinessOfMI.do",
				 businessOfMIData,
			 	'status:no;dialogWidth:800px;dialogHeight:600px'))
		return businessOfMIData;
	else
		return null;
}

//??????????????????????
function selectBusinessOfCL(){
	var businessOfCLData=new Object();
	if(popModalDialog( CONTEXT_ROOT + "system/common/selectBusinessOfCL.do",
				 businessOfCLData,
			 	'status:no;dialogWidth:800px;dialogHeight:600px'))
		return businessOfCLData;
	else
		return null;
}

//??????????????????????
function selectBusinessOfGC(){
	var businessOfGCData=new Object();
	if(popModalDialog( CONTEXT_ROOT + "system/common/selectBusinessOfGC.do",
				 businessOfGCData,
			 	'status:no;dialogWidth:800px;dialogHeight:600px'))
		return businessOfGCData;
	else
		return null;
}


//??????????????
function selectBranch(){
	var deptData=new Object();
	if(popModalDialog( CONTEXT_ROOT + "system/branch/ccrsBranch.do?operAtt=popWin",
				 deptData,
			 	'status:no;dialogWidth:800px;dialogHeight:600px'))
		return deptData;
	else
		return null;
}

//??????????????
function selectRegion(){
	var deptData=new Object();
	if(popModalDialog( CONTEXT_ROOT + "system/region/CmisRegion.do?operAtt=popWin",
				 deptData,
			 	'status:no;dialogWidth:800px;dialogHeight:600px'))
		return deptData;
	else
		return null;
}

//??????????????????
function selectCust(selApplyType){

   var custData=new Object();

   if(popModalDialog( CONTEXT_ROOT + "ci/selectCustBasInfo/selectCustBasInfo.do?applyType="+selApplyType,
				 custData,
			 	'status:no;dialogWidth:800px;dialogHeight:600px'))
		return custData;
	else
		return null;

}

//??????????(????GC????)
function selectCustByGC(){
   var cust=new Object();

   if(popModalDialog( CONTEXT_ROOT + "ci/selectCustBasInfo/selectCustByGC.do",
				 cust,
			 	'status:no;dialogWidth:800px;dialogHeight:600px'))
		return cust;
	else
		return null;

}

//??????????(????CL????)
function selectCustByCL(){
   var cust=new Object();

   if(popModalDialog( CONTEXT_ROOT + "ci/selectCustByCL/selectCustByCL.do",
				 cust,
			 	'status:no;dialogWidth:800px;dialogHeight:600px'))
		return cust;
	else
		return null;

}

//????????????????????????
function showCustBasInfo(selCustID){
   popModalDialog( CONTEXT_ROOT +
 "query/ciAction.do?operAtt=showDetails&selectCLIENT_ID="+selCustID
			,null,'status:no;dialogWidth:800px;dialogHeight:400px');
}

//????????????????
function selectPerson(){

   var custData=new Object();
   if(popModalDialog( CONTEXT_ROOT + "ci/natualPerson/selectPersonInfo.do",
				 custData,
			 	'status:no;dialogWidth:800px;dialogHeight:600px'))
		return custData;
	else
		return null;

}

//??????????????????
function selectEcoAttr(){
	var ecoAttrData=new Object();
	if(popModalDialog( CONTEXT_ROOT + "ci/selectEcoAttr/selectEcoAttr.do",
				 ecoAttrData,
			 	'status:no;dialogWidth:800px;dialogHeight:600px'))
		return ecoAttrData;
	else
		return null;
}

//??????????????????
function selectDictIdx(){
   var dictIdxData=new Object();

   if(popModalDialog( CONTEXT_ROOT + "system/common/selectDictIdx.do",
				 dictIdxData,
			 	'status:no;dialogWidth:800px;dialogHeight:600px'))
		return dictIdxData;
	else
		return null;

}
//??????????????
function selectOwnedDept(){
	var deptData=new Object();
	if(popModalDialog( CONTEXT_ROOT + "system/common/selectDepartment.do?actionType=ownedDept",
				 deptData,
			 	'status:no;dialogWidth:800px;dialogHeight:600px'))
		return deptData;
	else
		return null;
}

//??????????????
function inputOpinionDlg(dlgTitle,tabLable,info,maxSize){
	var opiData=new Object();
	opiData.title=dlgTitle;
	opiData.tabLable=tabLable;
	opiData.info=info;
	opiData.maxSize=maxSize;
	var sTime=new Date();
	sTime=sTime.valueOf();
	if(popModalDialog( CONTEXT_ROOT + "frame/inputOptnion.htm?time="+sTime,
				 opiData,
			 	'status:no;dialogWidth:600px;dialogHeight:400px'))
		return opiData.info;
	else
		return null;
}
function inputIdea(lcno,dlgTitle,tabLable,info,maxSize){
	var opiData=new Object();
	opiData.title=dlgTitle;
	opiData.tabLable=tabLable;
	opiData.info=info;
	opiData.maxSize=maxSize;
	var sTime=new Date();
	sTime=sTime.valueOf();
	if(popModalDialog( CONTEXT_ROOT + "mi/query/inputIdeaAction.do?lcno="+lcno+"&time="+sTime,
				 opiData,
			 	'status:no;dialogWidth:600px;dialogHeight:400px'))
		return opiData.info;
	else
		return null;
}



//??????????????????????
function selLmtDeptType(riskLevel){
	var deptType=new Object();
	if(popModalDialog( CONTEXT_ROOT + "cl/lmt/selDeptType.do?riskLevel="+riskLevel,
				 deptType,
			 	'status:no;dialogWidth:500px;dialogHeight:300px'))
		return deptType.deptType;
	else
		return null;
}

//???????????? ??????????
function lmtFinalDetailPopup(recNoFk,operAtt){
	var nullData=new Object();
	popModalDialog( CONTEXT_ROOT + "cl/lmt/finalDetail.do?recNoFk="+recNoFk+"&operAtt="+operAtt,
				 nullData,
			 	'status:no;dialogWidth:600px;dialogHeight:400px;')
	return null;
}

//???????????? ??????????
function lmtStaticDetailPopup(recNoFk,operAtt){
	var nullData=new Object();
	popModalDialog( CONTEXT_ROOT + "cl/lmt/staticDetail.do?recNoFk="+recNoFk+"&operAtt="+operAtt,
				 nullData,
			 	'status:no;dialogWidth:760px;dialogHeight:540px')
	return null;
}


//???????????????? ??????????,????????lmtType??????????????????????
function lmtInfoPopup(custID,regionCode,lmtCode){
	var nullData=new Object();
	var sUrl="cl/lmtReq/lmtInfoPopup.do?custID=";
	sUrl+=custID;
	sUrl+="&regionCode=";
	sUrl+=regionCode;
	sUrl+="&lmtCode=";
	sUrl+=lmtCode;
	popModalDialog( CONTEXT_ROOT + sUrl,
				 nullData,
			 	'status:no;dialogWidth:800px;dialogHeight:600px')
	return null;
}
//???????????????? ??????????
function lmtInfoByTypePopup(custID,regionCode,lmtCode,lmtType){
	var nullData=new Object();
	var sUrl="cl/lmtReq/lmtInfoPopup.do?custID=";
	sUrl+=custID;
	sUrl+="&regionCode=";
	sUrl+=regionCode;
	sUrl+="&lmtCode=";
	sUrl+=lmtCode;
	sUrl+="&lmtType=";
	sUrl+=lmtType;
	popModalDialog( CONTEXT_ROOT + sUrl,
				 nullData,
			 	'status:no;dialogWidth:800px;dialogHeight:600px')
	return null;
}
//GC????????????CI????????????????????????
function selectLnAccInfo(custID,regionCode){
   	var lnAccInfo=new Object();
   	var sUrl ="gc/createCred/lnAccInfo.do";
   	sUrl+="?custID=";
   	sUrl+=custID;
	sUrl+="&regionCode=";
	sUrl+=regionCode;
   if(popModalDialog( CONTEXT_ROOT + sUrl,
				 lnAccInfo,
			 	'status:no;dialogWidth:800px;dialogHeight:600px'))
		return lnAccInfo;
	else
		return null;
}
//GC????????????CI????????????????????????
function selectBalAccInfo(custID,regionCode){
   	var balAccInfo=new Object();
   	var sUrl ="gc/createCred/balAccInfo.do";
   	sUrl+="?custID=";
   	sUrl+=custID;
	sUrl+="&regionCode=";
	sUrl+=regionCode;
   if(popModalDialog( CONTEXT_ROOT + sUrl,
				 balAccInfo,
			 	'status:no;dialogWidth:800px;dialogHeight:600px'))
		return balAccInfo;
	else
		return null;
}
//GC??????????????????????
function selectRevOld(custID,regionCode){
   var lnAccInfo=new Object();
   var sUrl="gc/createCred/revOldSelect.do";
   	sUrl+="?custID=";
   	sUrl+=custID;
	sUrl+="&regionCode=";
	sUrl+=regionCode;
   if(popModalDialog( CONTEXT_ROOT + sUrl,
				 lnAccInfo,
			 	'status:no;dialogWidth:800px;dialogHeight:600px'))
		return lnAccInfo;
	else
		return null;
}
//GC??????????????????????
function showRepayPlan(repayTimes,credNo,lnAmt,payDate,matuDate){
	var saveNum=new Object();
	var sUrl="gc/createCred/repayPlanOperator.do";
	sUrl+="?repayTimes=";
   	sUrl+=repayTimes;
	sUrl+="&credNo=";
	sUrl+=credNo;
	sUrl+="&lnAmt=";
	sUrl+=lnAmt;
	sUrl+="&payDate=";
	sUrl+=payDate;
	sUrl+="&matuDate=";
	sUrl+=matuDate;
  	if(popModalDialog( CONTEXT_ROOT + sUrl ,
 			 saveNum,'status:no;dialogWidth:650px;dialogHeight:500px'))
  		return 	saveNum;
 	else
		return null;
}

//GC????????????????
function selectAcptDftListInfo(contNo,transferType){
   	var acptDftListInfo=new Object();
   	var sUrl ="gc/createCred/acptDftListInfo.do";
   	sUrl+="?contNo=";
   	sUrl+=contNo;
   	sUrl+="&transferType=";
   	sUrl+=transferType;

   if(popModalDialog( CONTEXT_ROOT + sUrl,
				 acptDftListInfo,
			 	'status:no;dialogWidth:1024px;dialogHeight:768px'))
		return acptDftListInfo;
	else
		return null;
}
//GC????????????????
function selectBGCont(custID,regionCode){
	var mainContCommData=new Object();
	var sUrl="gc/mainContract/bankGuarCont.do";
	sUrl+="?operAtt=toChooseCont";
	sUrl+="&custID=";
	sUrl+=custID;
	sUrl+="&regionCode=";
	sUrl+=regionCode;

	if(popModalDialog( CONTEXT_ROOT + sUrl,mainContCommData,'status:no;dialogWidth:800px;dialogHeight:600px'))
		return mainContCommData;
	else
		return null;
}
//GC????????????
function selectBGCred(contNo){
	var guarCredData=new Object();
	var sUrl="gc/mainContract/bankGuarCont.do";
	sUrl+="?operAtt=toChooseCred";
	sUrl+="&oldContNo=";
	sUrl+=contNo;
	if(popModalDialog( CONTEXT_ROOT + sUrl,guarCredData,'status:no;dialogWidth:800px;dialogHeight:600px'))
		return guarCredData;
	else
		return null;
}
//GC??????????
function selectRateCode(){
   var info=new Object();
   var sUrl="gc/rateCode.do";
   if(popModalDialog( CONTEXT_ROOT + sUrl,
				 info,
			 	'status:no;dialogWidth:800px;dialogHeight:600px'))
		return info;
	else
		return null;
}
//TT??????
function selectTTCode(){
   var info=new Object();
   var sUrl="gc/ttCode.do";
   if(popModalDialog( CONTEXT_ROOT + sUrl,
				 info,
			 	'status:no;dialogWidth:800px;dialogHeight:600px'))
		return info;
	else
		return null;
}
//????????????
function toClear(){
	with(document.forms[0]){
		for(i=0; i < elements.length; i++)
		{
			if (elements[i].type == "text")
			{
				elements[i].value="";
			}
			if (elements[i].type == "select-one")
			{
				elements[i].value="";
			}
			if (elements[i].type == "checkbox")
			{
				elements[i].checked=false;
			}
		}
	}
}

//??????????????????????????????
function selectGuardMember(){
	var guardMemberData=new Object();
	if(popModalDialog( CONTEXT_ROOT + "system/common/selectGuardMember.do?actionType=popWin",
				 guardMemberData,
			 	'status:no;dialogWidth:800px;dialogHeight:600px'))
		return guardMemberData;
	else
		return null;
}

//??????????????????????????????
function selectSanitationArea(){
	var saniAreaData=new Object();
	if(popModalDialog( CONTEXT_ROOT + "system/common/selectSanitationArea.do?actionType=popWin",
				 saniAreaData,
			 	'status:no;dialogWidth:800px;dialogHeight:600px'))
		return saniAreaData;
	else
		return null;
}

function SaveFile(docname){
   document.execCommand('SaveAs','',docname);
}


